package io.github.zatter.qiniucorejava.controller;

import io.github.zatter.qiniucorejava.utils.AudioProcessing;
import io.github.zatter.qiniucorejava.utils.TextProcessing;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@Slf4j
@RestController
public class ChatController {

    @Autowired
    TextProcessing textProcessing;

    @Autowired
    AudioProcessing audioProcessing;

    //语音对话接口
    @PostMapping("/AudioChat")
    public String AudioChat(@RequestParam("file") MultipartFile file,@RequestParam("role") String role){
        String test = audioProcessing.processAudio(file, role);
        return test;
    }

    //文字对话接口
    @GetMapping("/TextChat")
    public SseEmitter TextChat(@RequestParam("text") String text, @RequestParam("role") String role){
        return textProcessing.processTextStream("1",text,role);
    }
}
